package webx.actions;

import javax.swing.JOptionPane;

import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IMarkerDelta;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IStartup;

class MyList implements IResourceChangeListener{
	public void resourceChanged(final IResourceChangeEvent event){
			try {
				IMarkerDelta[] markerDeltas = event.findMarkerDeltas(null, true);
				if(markerDeltas.length>0){
					IMarker mm = markerDeltas[0].getMarker();
					if(mm.exists()){
						//System.out.println(event.findMarkerDeltas(null, true)[0].getResource()
						//		+","+mm.getAttribute(IMarker.LINE_NUMBER)
						//		+","+mm.getResource().getFullPath().toString()
						//		);
						BookMarkLink link = new BookMarkLink();
						Object num = mm.getAttribute(IMarker.LINE_NUMBER);
						if(num!=null){
							link.setLineNumber(num.toString());
							link.setLocation(mm.getResource().getFullPath().toString());
							link.setMessage(mm.getAttribute(IMarker.MESSAGE).toString());
							BoolMarkArea.link.add(link);
						}
					}
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
	}
}

public class Startup implements IStartup {
	public void earlyStartup() {
		ResourcesPlugin.getWorkspace().addResourceChangeListener(new MyList());
		Display.getDefault().syncExec(new Runnable() {
	         public void run() {
	        	 try{
	        	 JettyServer.start(); 
	        	 //new FindRun1().start();
	        	 }catch(Throwable e){
	        		 JOptionPane.showMessageDialog(null, "sss"+e);
	        	 } 
	         }
	      });
	   }
	public static void main(String[]args){
		System.out.println(Startup.class.getResource("/etc/jetty.xml").getFile());
		
	}
}